package cn.ycc1.feign.clients.fallback;

import cn.ycc1.feign.clients.UserClient;
import cn.ycc1.feign.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * @Title:
 * @Author ycc
 * @Date 2023/7/15 19:36
 */
@Slf4j
public class UserClientFallbackFactory implements FallbackFactory<UserClient> {
    @Override
    public UserClient create(Throwable cause) {
        return new UserClient() {
            @Override
            public User findByUsername(String username) {
                log.error("根据用户名-查询用户异常", cause);
                return new User();
            }

            @Override
            public User findByUserId(String userId) {
                log.error("根据用户ID-查询用户异常", cause);
                return new User();
            }
        };
    }
}
